<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zoga.dao.${entityName}Dao">
    <!-- <insert id="" parameterType="" useGeneratedKeys="true" keyProperty="id"> -->
    <!--
        <choose>
            <when test="">

            </when>
            <otherwise>

            </otherwise>
        </choose>
    -->
    <!--
        <foreach collection="list" item="item" index="index" separator=",">
            <trim prefix=" (" suffix=")" suffixOverrides=",">

            </trim>
        </foreach>
    -->

    <resultMap id="BaseResultMap" type="${entityPackaging}.${entityName}">
${baseResultMap}
    </resultMap>

    <sql id="Base_Column_List" >
${baseColumnList}
    </sql>

    <select id="selectByParam" resultMap="BaseResultMap" parameterType="${entityPackaging}.${entityName}Query" >
        select
            <include refid="Base_Column_List" />
        from ${nameOriginal}
        <where>
${selectWhere}
        </where>
    </select>

    <insert id="insert" parameterType="${entityPackaging}.${entityName}" useGeneratedKeys="true" keyProperty="id">
        insert into ${nameOriginal}
        <trim prefix="(" suffix=")" suffixOverrides="," >
${insertInto}
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides="," >
${insertIntoValue}
        </trim>
    </insert>

    <insert id="insertBatch" parameterType="${entityPackaging}.${entityName}">
        insert into ${nameOriginal}
        <trim prefix="(" suffix=")" suffixOverrides="," >
${insertInto}
        </trim>
        values
        <foreach collection="list" item="item" index="index" separator=",">
            <trim prefix="(" suffix=")" suffixOverrides="," >
${insertIntoForeachValue}
            </trim>
        </foreach>
    </insert>

    <update id="updateById" parameterType="${entityPackaging}.${entityName}" >
        update ${nameOriginal}
        <set>
${updateSet}
        </set>
        where id = #{ ${keyColumnLower} }
    </update>

</mapper>